﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:chronos="http://chronos/schemas/2010/xaml">
        
    <!-- Global Settings-->
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Colors.xaml"/>
        <ResourceDictionary Source="Brushes.xaml"/>
        <ResourceDictionary Source="Fonts.xaml"/>
        <ResourceDictionary Source="CoreStyles.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <!--Widget Style-->
    <Style x:Key="DefaultWidgetStyle" TargetType="{x:Type chronos:WidgetElement}">
        <Setter Property="Id" Value="{Binding Id}"/>
        <Setter Property="FontSize" Value="{StaticResource ContentFontSize}" />
        <Setter Property="Background" Value="{StaticResource GradientBackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="MinWidth" Value="100"/>
        <Setter Property="MinHeight" Value="53"/>
        <Setter Property="Width" Value="Auto" />
        <Setter Property="Height" Value="Auto" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="ConstraintToParent" Value="True" />
        <Setter Property="AllowDrop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type chronos:WidgetElement}">
                    <Grid>
                        <Border x:Name="Chrome"
                                Grid.RowSpan="2"
                                Background="{TemplateBinding Background}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"                                
                                CornerRadius="5,0,5,0" />

                        <Grid Margin="3.5">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                        
                            <Grid Grid.Row="0">

                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition x:Name="HeaderLeftPartColumn" Width="*" />
                                    <ColumnDefinition x:Name="HeaderRightPartColumn" Width="65" />
                                </Grid.ColumnDefinitions>

                                <Rectangle x:Name="PART_Dragger"
                                           Grid.ColumnSpan="2"
                                           Margin="3.5"
                                           Fill="Transparent" />

                                <Grid Grid.Column="0" Margin="3.5">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="10" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>

                                    <Rectangle x:Name="GradientBrand" Grid.Row="0"
                                               VerticalAlignment="Bottom" HorizontalAlignment="Left"
                                               Fill="{StaticResource AccentColorBlueBrush}" 
                                               Width="109" Height="6" 
                                               IsHitTestVisible="False" />

                                    <TextBlock Grid.Row="1"
                                               FontFamily="{StaticResource HeaderFontFamily}" FontSize="{StaticResource HeaderFontSize}" FontWeight="SemiBold"
                                               HorizontalAlignment="Left" VerticalAlignment="Center"
                                               Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}" 
                                               IsHitTestVisible="False">
                                    </TextBlock>
                                </Grid>

                                <StackPanel x:Name="HeaderRightPartContent" 
                                            Grid.Column="1" 
                                            Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right">

                                    <Button x:Name="PART_MinimizeButton"
                                            Style="{StaticResource MetroButtonStyle}"
                                            Command="chronos:WidgetElement.MinimizeCommand"
                                            VerticalAlignment="Center" Margin="1.5"
                                            ToolTip="Minimize">
                                        <TextBlock TextWrapping="Wrap" Text="0" FontFamily="Webdings" FontSize="13.333" FontWeight="Normal"/>
                                    </Button>
                                                                        
                                    <Button x:Name="PART_CloseButton"
                                            Style="{StaticResource MetroButtonStyle}"
                                            Command="{Binding CloseCommand}"
                                            VerticalAlignment="Center" Margin="1.5"
                                            ToolTip="Close">
                                        <TextBlock TextWrapping="Wrap" Text="r" FontFamily="Webdings" FontSize="13.333" FontWeight="Normal"/>
                                    </Button>
                                </StackPanel>
                            </Grid>

                            <Grid Grid.Row="2">                                
                                <ContentPresenter x:Name="PART_ContentPresenter"
                                                  Content="{TemplateBinding Content}"
                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                            </Grid>
                        </Grid>
                    </Grid>
                    
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsActive" Value="False">
                            <Setter TargetName="GradientBrand" Property="Fill" Value="{StaticResource AccentColorGreenBrush}" />
                        </Trigger>

                        <Trigger Property="WidgetState" Value="Minimized">
                            <Setter TargetName="PART_ContentPresenter" Property="Visibility" Value="Collapsed" />
                        </Trigger>

                        <Trigger Property="WidgetState" Value="Normal">
                            <Setter TargetName="PART_ContentPresenter" Property="Visibility" Value="Visible" />
                        </Trigger>

                        <Trigger Property="ShowMinimizeButton" Value="False">
                            <Setter TargetName="PART_MinimizeButton" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!--Gadget Style-->
    <Style x:Key="VisibleResizeGrip"
           TargetType="{x:Type ResizeGrip}">
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="Margin"
                Value="0,0,1,1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ResizeGrip}">
                    <Grid SnapsToDevicePixels="True"
                          Background="Transparent">
                        <Path Fill="{StaticResource GripperShadowBrush}"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Data="
                              M 9,1 L 11,1 L 11,3 L 9,3 Z 
                              M 5,5 L 7,5 L 7,7 L 5,7 Z 
                              M 9,5 L 11,5 L 11,7 L 9,7 Z 
                              M 1,9 L 3,9 L 3,11 L 1,11 Z 
                              M 5,9 L 7,9 L 7,11 L 5,11 Z 
                              M 5,1 L 7,1 L 7,3 L 5,3 Z 
                              M 1,1 L 3,1 L 3,3 L 1,3 Z 
                              M 1,5 L 3,5 L 3,7 L 1,7 Z 
                              M 1,13 L 3,13 L 3,15 L 1,15 Z 
                              M 5,13 L 7,13 L 7,15 L 5,15 Z 
                              M 9,13 L 11,13 L 11,15 L 9,15 Z 
                              M 9,9 L 11,9 L 11,11 L 9,11 Z" />
                        <Path Fill="{StaticResource GripperHighlightBrush}"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Data="
                              M 8,0 L 10,0 L 10,2 L 8,2 Z 
                              M 4,4 L 6,4 L 6,6 L 4,6 Z 
                              M 8,4 L 10,4 L 10,6 L 8,6 Z 
                              M 0,8 L 2,8 L 2,10 L 0,10 Z 
                              M 4,8 L 6,8 L 6,10 L 4,10 Z 
                              M 4,0 L 6,0 L 6,2 L 4,2 Z 
                              M 0,0 L 2,0 L 2,2 L 0,2 Z 
                              M 0,4 L 2,4 L 2,6 L 0,6 Z 
                              M 0,12 L 2,12 L 2,14 L 0,14 Z 
                              M 4,12 L 6,12 L 6,14 L 4,14 Z 
                              M 8,12 L 10,12 L 10,14 L 8,14 Z 
                              M 8,8 L 10,8 L 10,10 L 8,10 Z" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>  
    
    <Style x:Key="DefaultGadgetStyle" TargetType="{x:Type chronos:WidgetElement}">
        <Setter Property="Id" Value="{Binding Id}"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Width" Value="Auto" />
        <Setter Property="Height" Value="Auto" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="ConstraintToParent" Value="True" />
        <Setter Property="CanResize" Value="False" />
        <Setter Property="AllowDrop" Value="False" />
        <Setter Property="ShowMinimizeButton" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type chronos:WidgetElement}">
                    <Grid ToolTip="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="21" />
                        </Grid.ColumnDefinitions>
                        
                        <Border x:Name="Chrome"
                                Grid.Column="0" Grid.ColumnSpan="2"
                                Background="{StaticResource GadgetBackgroundBrush}" 
                                CornerRadius="5"
                                Visibility="Collapsed" />								
                        
                        <Grid x:Name="SideBar" 
                              Grid.Column="1" 
                              HorizontalAlignment="Right" VerticalAlignment="Top">

                            <Grid.RowDefinitions>
                                <RowDefinition Height="3.5" />
                                <RowDefinition Height="18" />
                                <RowDefinition Height="3.5" />
                                <RowDefinition Height="22" />
                                <RowDefinition Height="3.5" />
                            </Grid.RowDefinitions>
                            
                            <Border x:Name="ControlBarBorder"
                                    Grid.Row="0" Grid.RowSpan="5"
                                    Background="{StaticResource ControlBarBackgroundBrush}"
                                    BorderBrush="{StaticResource ControlBarBorderBrush}" BorderThickness="1"
                                    CornerRadius="3"
                                    Padding="1"
                                    Width="20" Height="63" />

                            <Button x:Name="PART_CloseButton"
                                    Grid.Row="1"
                                    Style="{StaticResource MetroButtonStyle}"
                                    Command="{Binding CloseCommand}"
                                    VerticalAlignment="Top"
                                    Margin="1.5"
                                    ToolTip="Close">
                                <TextBlock TextWrapping="Wrap" Text="r" FontFamily="Webdings" Foreground="{StaticResource WhiteBrush}" FontSize="11.333" FontWeight="Normal"/>
                            </Button>
                            
                            <ResizeGrip x:Name="PART_Dragger"
                                        Grid.Row="3"
                                        Margin="3.5"
                                        VerticalAlignment="Stretch" HorizontalAlignment="Center"
                                        Style="{StaticResource VisibleResizeGrip}" />
                        </Grid>

                        <Grid Grid.Column="0" Margin="3.5">
                            <ContentPresenter x:Name="PART_ContentPresenter"
                                              Content="{TemplateBinding Content}"
                                              ContentTemplate="{TemplateBinding ContentTemplate}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </Grid>
                    </Grid>
                    
                    <ControlTemplate.Triggers>                      
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="SideBar" Property="Visibility" Value="Visible" />
                            <Setter TargetName="Chrome" Property="Visibility" Value="Visible" />
                            <Setter TargetName="Chrome" Property="Opacity" Value="0.15" />
                        </Trigger>

                        <Trigger Property="IsMouseOver" Value="False">
                            <Setter TargetName="SideBar" Property="Visibility" Value="Hidden" />
                        </Trigger>
                        
                        <EventTrigger RoutedEvent="Activated">
                            <EventTrigger.Actions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                                         BeginTime="0:0:0"
                                                         To="1.0"
                                                         Duration="0:0:1" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="Deactivated">
                            <EventTrigger.Actions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                                         BeginTime="0:0:0"
                                                         To="0.85"
                                                         Duration="0:0:1" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>